export class Student {
  id: string;
  name: string;
  classId: string;
  className: string;
  score: number;
  hearImg: string;
  answerID: string;
  cretivity: number;//学生创造性
  cretivityArr: any;
  noCretivityArr: any;
  cretivityDesc: string;//学生创造力描述
  constructor(id: string, score: string, classId: string, className: string, answerID: string) {
    this.id = id;
    this.score = parseInt(score);
    this.classId = classId;
    this.className = className;
    this.answerID = answerID;
    this.cretivityArr = [];
    this.noCretivityArr = [];
    this.countScore();

  }

  initInfo(name, hearImg) {
    if (hearImg) {
      this.hearImg = 'http://static.lessonplan.cn/' + hearImg;
    } else {
      this.hearImg = '/assets/img/image/datouxiang.png';
      this.name = name;
    }
  }

  //计算学生创造性
  countScore() {
    if (this.score >= 95) {
      //创造性非凡
      this.cretivityDesc = '创造性非凡';
      this.cretivity = 5;
    } else if (this.score >= 65) {
      this.cretivityDesc = '很有创造性';
      this.cretivity = 4;
    } else if (this.score >= 40) {
      this.cretivityDesc = '创造性高于平均';
      this.cretivity = 3;
    } else if (this.score >= 20) {
      this.cretivityDesc = '创造性平均水平';
      this.cretivity = 2;
    } else if (this.score >= 10) {
      this.cretivityDesc = '创造性低于平均';
      this.cretivity = 1;
    } else {
      this.cretivityDesc = '没有创造性';
      this.cretivity = 0;
    }
    this.cretivityArr.length = this.cretivity;
    this.noCretivityArr.length = 5 - this.cretivity
  }

//  当成绩发生变化时重新计算成绩
  anewScore(score: string) {
    this.score = parseInt(score);
    this.countScore()
  }
}
